package com.hqq.service.impl;

import com.hqq.dao.WoocUserDao;
import com.hqq.domain.WoocUser;
import com.hqq.service.WoocUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * WoocUserServiceImpl
 * Created by heqianqian on 2018/3/25.
 */
@Service
public class WoocUserServiceImpl implements WoocUserService {
    private static final Logger logger = LoggerFactory.getLogger(WoocUserServiceImpl.class);

    @Autowired
    private WoocUserDao woocUserDao;

    @Override
    public WoocUser checkLogin(String name, String pwd, Integer type) throws Exception {
        WoocUser woocUser = WoocUser.builder()
                .userName(name)
                .userPwd(pwd)
                .userType(type)
                .build();

        return woocUserDao.findWoocUser(woocUser);
    }

    @Override
    public WoocUser saveUser(String userName, String pwd) throws Exception {

        WoocUser woocUser = WoocUser.builder()
                .userName(userName)
                .userPwd(pwd)
                .build();

        woocUserDao.insertUser(woocUser);
        return woocUser;
    }
}
